package com.hrsoft.edi.qimen.listener;

import com.hrsoft.edi.stub.request.EntryorderConfirmRequest;
import org.springframework.stereotype.Component;

import com.hrsoft.edi.qimen.QimenListenner;
import com.hrsoft.edi.stub.internal.QimenXmlRequestParser;
import com.hrsoft.edi.util.QimenUtils;
import com.taobao.api.ApiException;

import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class EntryOrderConfirmListenner implements QimenListenner
{
    @Override
    public String doBiz(String xml, Object appInfo)
    {
        QimenXmlRequestParser<EntryorderConfirmRequest> converter =
            new QimenXmlRequestParser(EntryorderConfirmRequest.class);
        
        EntryorderConfirmRequest request = null;
        
        try
        {
            request = converter.parse(xml, "request");
        }
        catch (ApiException e)
        {
            log.error("Qimen xml 解析失败", e);
            throw new RuntimeException("Qimen xml 解析失败");
        }

        // TODO 做自己的业务逻辑 冥等性处理等
        request.getEntryOrder().getEntryOrderCode();
        
        return QimenUtils.getCommonResponse("200", "success", null);
    }
}
